﻿using System;
using System.Collections.Generic;
using System.Text;
using Little.Soldier.SWIFT.Validation;

namespace ConsoleApplication15
{
    public class Tag13CValidator : ValidateTagBase
    {
        public Tag13CValidator(string tagName)
            : base(tagName)
        { }

        public Tag13CValidator(string tagName, bool allowEmptyValue)
            : base(tagName, allowEmptyValue)
        { }

        protected override void InitializeRules()
        {
            // TimeIndication (13C:/CLSTIME/0910+0100)

            // Code (CLSTIME)
            Rules.Add(new ValidationRule_Length(1, 8, '/', 1));
            Rules.Add(new ValidationRule_RegEx("[A-Z0-9]*",'/', 1));

            // TimeIndicator (0910)
            ValidationRule_RegEx regExTimeIndicator = new ValidationRule_RegEx("([0-1][0-9]|2[0-3])[0-5][0-9]");
            regExTimeIndicator.Delimiter = '/';
            regExTimeIndicator.Count = 2;
            regExTimeIndicator.StartIndex = 0;
            regExTimeIndicator.Length = 4;
            Rules.Add(regExTimeIndicator);

            // Sign (+)
            ValidationRule_RegEx regExSign = new ValidationRule_RegEx(@"(\+|\-)", 4, 1);
            regExSign.Delimiter = '/';
            regExSign.Count = 2;
            Rules.Add(regExSign);

            // TimeOffset (0100)
            ValidationRule_RegEx regExTimeOffset = new ValidationRule_RegEx("(0[0-9]|1[0-3])[0-5][0-9]", 5, 4);
            regExTimeOffset.Delimiter = '/';
            regExTimeOffset.Count = 2;
            Rules.Add(regExTimeOffset);
        }
    }
}


